// 一些miniui的公共函数
function newtab(name, url, iconCls) {
    var name = name;
    var tab = tabs.getTab(name);
    if (!tab) {
        tab = {};
        tab.name = name;
        tab.title = name;
        tab.url = url;
        tab.showCloseButton = true;
        tab.iconCls = iconCls;
        tab.onload = function () {
            var iframe = tabs.getTabIFrameEl(tab);
            var hei = iframe.contentWindow.document.body.scrollHeight + 150;
            iframe.style.height = hei + 'px';
        };
        tab.ondestroy = function () {
            tabs.activeTab(tabs.getTab("主数据表"));
        };
        tabs.addTab(tab);
    }
    else if (tab.url != url) {
        tab.url = url;
        tabs.reloadTab(tab);
    }
    tabs.activeTab(tab);
}

// 地区的弹出输入框
var grid_region = mini.get("datagrid_region");
var keyText_region = mini.get("keyText_region");
var lookup_region = mini.get("lookup_region");
if (grid_region) grid_region.load();
function onSearchClick_region(e) {
    grid_region.load({name: keyText_region.value});
}
function onCloseClick_region(e) {
    lookup_region.hidePopup();
}
function onClearClick_region(e) {
    lookup_region.deselectAll();
    grid_region.load();
}

// 统计行业分类的输入框
var grid_nic = mini.get("datagrid_nic");
var keyText_nic = mini.get("keyText_nic");
var lookup_nic = mini.get("lookup_nic");
if (grid_nic) grid_nic.load();
function onSearchClick_nic(e) {
    grid_nic.load({name: keyText_nic.value});
}
function onCloseClick_nic(e) {
    lookup_nic.hidePopup();
}
function onClearClick_nic(e) {
    lookup_nic.deselectAll();
    grid_nic.load();
}

// 统计行业分类的输入框
var grid_elnic = mini.get("datagrid_elnic");
var keyText_elnic = mini.get("keyText_elnic");
var lookup_elnic = mini.get("lookup_elnic");
if (grid_elnic) grid_elnic.load();
function onSearchClick_elnic(e) {
    grid_elnic.load({name: keyText_elnic.value});
}
function onCloseClick_elnic(e) {
    lookup_elnic.hidePopup();
}
function onClearClick_elnic(e) {
    lookup_elnic.deselectAll();
    grid_elnic.load();
}

// 战兴产业分类的输入框
var grid_elseic = mini.get("datagrid_elseic");
var keyText_elseic = mini.get("keyText_elseic");
var lookup_elseic = mini.get("lookup_elseic");
if (grid_elseic) grid_elseic.load();
function onSearchClick_elseic(e) {
    grid_elseic.load({name: keyText_elseic.value});
}
function onCloseClick_elseic(e) {
    lookup_elseic.hidePopup();
}
function onClearClick_elseic(e) {
    lookup_elseic.deselectAll();
    grid_elseic.load();
}

// 企业类型的输入框
var grid_enttype = mini.get("datagrid_enttype");
var keyText_enttype = mini.get("keyText_enttype");
var lookup_enttype = mini.get("lookup_enttype");
if (grid_enttype) grid_enttype.load();
function onSearchClick_enttype(e) {
    grid_enttype.load({name: keyText_enttype.value});
}
function onCloseClick_enttype(e) {
    lookup_enttype.hidePopup();
}
function onClearClick_enttype(e) {
    lookup_enttype.deselectAll();
    grid_enttype.load();
}

//禁止选择大于今天的日期
function onDrawDate(e) {
    var date = e.date;
    var d = new Date();

    if (date.getTime() > d.getTime()) {
        e.allowSelect = false;
    }
}

// 字段清洗，去除首尾的空白和￥字符
function fclean(v) {
    return v.replace(/^\s\s*/, '').replace(/\s\s*$/, '').replace("￥", '').replace("$", '');
}

// 字段清洗，如果有数值，乘以10000
function fwan(v) {
    if (v != '') {
        return (v * 10000).toString();
    }
    else {
        return v;
    }
}

// 隐藏筛选器
function hidesearch(m) {
    if (m == 'hide') $('#form_search').hide();
    if (m == 'show') $('#form_search').show();
}

// 表格的条纹样式
function tableborder(hv, m) {
    if (hv == 'h') {
        grid_main.setShowHGridLines(m);
    }
    else if (hv == 'v') {
        grid_main.setShowVGridLines(m);
    }
}

//网上找的阻止miniui试用到期弹窗
var WinAlerts = window.alert;
window.alert = function (e) {
    if (e != null && (e.indexOf("www.miniui.com") > -1)) {
    }
    else {
        WinAlerts(e);
    }
};
